package com.ml.doctor.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ml.doctor.R;
import com.ml.doctor.bean.AccountHistoryBean;

import java.util.ArrayList;

public class AccountRecyclerAdapter extends RecyclerView.Adapter<AccountRecyclerAdapter.HistoryHolder> {
    public LayoutInflater mInflater;
    public ArrayList<AccountHistoryBean> mDataList;

    public AccountRecyclerAdapter(Context context){
        mInflater = LayoutInflater.from(context);
        mDataList = new ArrayList<>();
        mDataList.add(new AccountHistoryBean("首签", "2017-7-7", "+100"));
        mDataList.add(new AccountHistoryBean("视频服务", "2017-8-13", "+10"));
        mDataList.add(new AccountHistoryBean("视频服务", "2017-9-1", "+20"));
        mDataList.add(new AccountHistoryBean("视频服务", "2017-10-17", "+30"));
        mDataList.add(new AccountHistoryBean("视频服务", "2017-9-27", "+100"));
    }

    @Override
    public HistoryHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new HistoryHolder(mInflater.inflate(R.layout.item_account_layout, null));
    }

    @Override
    public void onBindViewHolder(HistoryHolder holder, int position) {
        AccountHistoryBean itemBean = mDataList.get(position);
        holder.mSourceTv.setText(itemBean.source);
        holder.mCountTv.setText(itemBean.count);
        holder.mTimeTv.setText(itemBean.time);
    }

    @Override
    public int getItemCount() {
        return mDataList.size();
    }

    class HistoryHolder extends RecyclerView.ViewHolder{
        public TextView mSourceTv;
        public TextView mCountTv;
        public TextView mTimeTv;

        public HistoryHolder(View view){
            super(view);
            mSourceTv = (TextView) view.findViewById(R.id.tv_item_source);
            mTimeTv = (TextView) view.findViewById(R.id.tv_item_time);
            mCountTv = (TextView) view.findViewById(R.id.tv_item_count);
        }
    }
}
